package com.ss.android.article.base.feature.feed.presenter;

import com.ss.android.article.base.feature.model.CellRef;
import com.ss.android.b.a.AdsAppItem;

import java.util.ArrayList;
import java.util.EnumSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONObject;

public final class ArticleQueryObj {
    public enum CtrlFlag {
        onVideoTab
    }


    public final class StreamReqStatParamsAssembler {
        LinkedList<RequestSession> requestSessionLinkedList = new LinkedList();

        public final JSONObject assembleParams() {
            if (this.requestSessionLinkedList == null) {
                return null;
            }

            JSONObject jsonObject = new JSONObject();
            JSONArray statJA = new JSONArray();
            try {
                Iterator<RequestSession> iterator = this.requestSessionLinkedList.iterator();
                while (iterator.hasNext()) {
                    RequestSession requestSession = iterator.next();
                    JSONObject jo = new JSONObject();
                    jo.put("using_https", requestSession.usingHttps);
                    jo.put("status", requestSession.status);
                    jo.put("remote_ip", requestSession.remoteIp);
                    jo.put("req_time", requestSession.reqTime);
                    jo.put("content_hijack", requestSession.contentHijack);
                    jo.put("ss_sign", requestSession.ssSign);
                    jo.put("local_sign", requestSession.localSign);
                    jo.put("raw_sign", requestSession.rawSign);
                    jo.put("is_2g", requestSession.is2g);
                    jo.put("https_fail_times", requestSession.httpsFailTimes);
                    jo.put("https2http", requestSession.https2http);
                    jo.put("http_quest_time", requestSession.httpQuestTime);
                    jo.put("http_retry", requestSession.httpRetry);
                    jo.put("show_hijack", requestSession.showHijack);
                    jo.put("is_strict", requestSession.isStrict);
                    jo.put("body_is_json", requestSession.bodyIsJson);
                    jo.put("decode_time", requestSession.decodeTime);
                    if (!android.support.design.a.isTextEmpty(requestSession.exception)) {
                        jo.put("exception", requestSession.exception);
                    }
                    if (!android.support.design.a.isTextEmpty(requestSession.exceptionMsg)) {
                        jo.put("exception_msg", requestSession.exceptionMsg);
                    }
                    statJA.put(jo);
                }
                jsonObject.put("stat_list", statJA);
            } catch (Throwable throwable) {
                throwable.printStackTrace();
            }
            return jsonObject;
        }
    }

    public static final class RequestSession {
        public boolean usingHttps;
        public int status;
        public String remoteIp;
        public long reqTime;
        public boolean contentHijack = false;
        public String ssSign;
        public String localSign;
        public String rawSign;
        public boolean is2g;
        public int httpsFailTimes;
        public boolean https2http;
        public int httpQuestTime;
        public boolean httpRetry;
        public boolean showHijack;
        public boolean isStrict;
        public boolean bodyIsJson;
        public long decodeTime;
        public String exception;
        public String exceptionMsg;
    }

    public String errorIp;
    public String exception;
    public String exceptionMsg;
    public int showEtStatus;
    public long E;
    public String postContentHint;
    public int respOffset;
    public String apiParam;
    public boolean loginStatus;
    public String extra;
    public int feedFlag;
    public boolean hasMoreToRefresh;
    public int actionToLastStick;
    public boolean isRefreshing;
    public boolean O;
    public long movieId;
    public String jsonQuery;
    public AdsAppItem mAdsAppItem;
    public List subEntranceList;
    public boolean T;
    public String historyType;
    public int refreshReason;
    public StreamReqStatParamsAssembler mStreamReqStatParamsAssembler;
    public EnumSet X;
    public long netRequestTime;
    public long localLoadTime;
    public final int categoryType;
    public long startTime;
    public boolean errorOccur;
    public long responseParseCost;
    public long responseStartParseTs;
    public long responseFinishParseTs;
    public long updateDbCost;
    public long updateDbStartTs;
    public long updateDbEndTs;
    public long startRequestTimeStamp;
    public long finishRequestTimeStamp;
    public final int b;
    public final String category;
    public final boolean d;
    public final long minBehotTime;
    public final long maxBehotTime;
    public final int offset;
    public final int count;
    public final String ttFrom;
    public final boolean j;
    public final String userCity;
    public final long l;
    public final int refer;
    public final long concernId;
    public long o;
    public boolean hasMore;
    public List q;
    public List<CellRef> r;
    public List s;
    public boolean t;
    public long u;
    public boolean v;
    public long firstCateBehotTime;
    public long lastCateBehotTime;
    public int errorCode;
    public int cid;

    public ArticleQueryObj(int arg21, boolean arg22, long arg23, boolean arg25, long arg26) {
        this(2, arg21, "", arg22, 0, arg23, 0, 20, arg25, null, null, arg26, 0, 0);
    }

    public ArticleQueryObj(int arg21, long arg22, int arg24) {
        this(arg24, arg21, "", false, 0, arg22, 0, 20, false, null, null, 0, 0, 0);
    }

    public ArticleQueryObj(int arg22, String arg23, long arg24, String arg26, String arg27) {
        this(1, arg22, arg23, true, 0, arg24, 0, 10, false, arg26, arg27, -1, 1, 0);
    }

    public ArticleQueryObj(int arg23, String arg24, boolean arg25, long arg26, long arg28, boolean arg30, String arg31, String arg32, EnumSet arg33, int arg34, long arg35) {
        this(1, arg23, arg24, arg25, arg26, arg28, 0, 20, arg30, arg31, null, -1, arg34, arg35);
        this.extra = arg32;
        this.X = arg33;
    }

    public ArticleQueryObj(int arg23, String arg24, boolean arg25, long arg26, long arg28, int arg30,
                           boolean arg31, String arg32, String arg33, EnumSet arg34, int arg35,
                           long arg36, String arg38) {
        this(5, arg23, arg24, arg25, arg26, arg28, arg30, 20, arg31, arg32, null, -1, arg35, arg36);
        this.extra = arg33;
        this.X = arg34;
        this.jsonQuery = arg38;
    }

    public ArticleQueryObj(int arg25, String arg26, boolean arg27, long arg28, long arg30, boolean arg32, String arg33, String arg34, int arg35, long arg36, String arg38, long arg39) {
        this(7, arg25, arg26, arg27, arg28, arg30, 0, 20, arg32, arg33, null, -1, arg35, arg36);
        this.extra = arg34;
        this.apiParam = arg38;
        this.o = arg39;
    }

    private ArticleQueryObj(int arg6, int arg7, String category, boolean arg9, long minBehotTime, long maxBehotTime, int arg14, int count, boolean arg16, String ttFrom, String userCity, long arg19, int refer, long concernId) {
        this.mStreamReqStatParamsAssembler = new StreamReqStatParamsAssembler();
        this.netRequestTime = -1;
        this.localLoadTime = -1;
        this.errorOccur = false;
        this.categoryType = arg6;
        this.b = arg7;
        this.category = category;
        this.d = arg9;
        this.minBehotTime = minBehotTime;
        this.maxBehotTime = maxBehotTime;
        this.offset = arg14;
        this.count = count;
        this.ttFrom = ttFrom;
        this.j = arg16;
        this.userCity = userCity;
        this.l = arg19;
        this.startTime = System.currentTimeMillis();
        this.subEntranceList = new ArrayList();
        this.refer = refer;
        this.concernId = concernId;
    }
}

